# -*- coding: utf-8 -*-

# File Name： cabinet
# Description :
# Author : lirui
# create_date： 2022/9/15
# Change Activity:
from modules.generate_label.obj.u_info import UInfo


class Cabinet:
    def __init__(self, xls_info, cabinet_name):
        """

        Args:
            xls_info:
            cabinet_name:
        """
        self.xls_info = xls_info
        self.cabinet_name = cabinet_name
        self.u_mapping = self._collect_u_mapping(xls_info)
        pass

    @staticmethod
    def _collect_u_mapping(xls_info):
        """

        Returns:

        """
        u_mapping = {}
        for info in xls_info:
            u_name = info['本端U数']
            if u_name not in u_mapping:
                u_mapping[u_name] = []
            u_mapping[u_name].append(info)
        u_obj_mapping = {}
        for u_name, info in u_mapping.items():
            u_obj_mapping[u_name] = UInfo(info)
        return u_obj_mapping
